#include "Packet.hpp"


Packet::Packet() : Data(NULL), Length(0) {
}

Packet::Packet(const unsigned char *Data, unsigned int Length) : Data(Data), Length(Length) {
}

void Packet::Set(const unsigned char *Data, unsigned int Length) {
	this->Data = Data;
	this->Length = Length;
}

const unsigned char* Packet::GetData() const {
	return Data;
}

unsigned int Packet::GetLength() const {
	return Length;
}

Block Packet::GetBSSID() const {
	return Block(&Data[22], 6);
}

Block Packet::GetSrcMAC() const {
	return Block(&Data[28], 6);
}

Block Packet::GetDstMAC() const {
	return Block(&Data[16], 6);
}

Block Packet::GetWEP_IV() const {
	return Block(&Data[36], 3);
}

Block Packet::GetWEP_Payload() const {
	return Block(&Data[40], Length - 40 - 4);
}

void Packet::Dump() const {
	std::cerr << "Len = " << Length << std::endl;
	for (unsigned int i = 0; i < Length; i++) {
		std::cerr << "   " << (int)Data[i] << std::endl;
	}
}
